<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/4
 * Time: 15:07
 */

namespace app\admin\controller;


class Index extends common
{
    public function index(){
        return $this->fetch();
    }
    public function welcome(){
        $usersum = db('user')->count();
        $dlsum = db('user')->where('lv',1)->count();
        $hysum = db('user')->where('lv',2)->count();

        $todayuser = db('user')->where('login_time','>',strtotime(date("Y-m-d"),time()))->count();
        $todaydl = db('user')->where('lv',1)->where('login_time','>',strtotime(date("Y-m-d"),time()))->count();
        $todayhy =  $todayuser - $todaydl;

        $ytodayuser = db('user')->where('login_time','>',strtotime(date("Y-m-d",strtotime("-1 day")),time()))->where('login_time','<',strtotime(date("Y-m-d"),time()))->count();
        $ytodaydl = db('user')->where('lv',1)->where('login_time','>',strtotime(date("Y-m-d",strtotime("-1 day")),time()))->where('login_time','<',strtotime(date("Y-m-d"),time()))->count();
        $ytodayhy =  $ytodayuser - $ytodaydl;
        //在线人数
        $online = db('user')->where('on_line','>=',time())->count();
        $this->assign('online',$online);
        //总金额
        $moneysum= db('user')->sum('money');
        $this->assign('moneysum',$moneysum);
        //总数
        $this->assign('usersum',$usersum);
        $this->assign('dlsum',$dlsum);
        $this->assign('hysum',$hysum);
        //今日
        $this->assign('todayuser',$todayuser);
        $this->assign('todaydl',$todaydl);
        $this->assign('todayhy',$todayhy);
        //昨日
        $this->assign('ytodayuser',$ytodayuser);
        $this->assign('ytodaydl',$ytodaydl);
        $this->assign('ytodayhy',$ytodayhy);
        return $this->fetch();
    }

}